import { _decorator, Component, Node } from 'cc';
import { ControllerBase } from './ControllerBase';
const { ccclass, property } = _decorator;

export class ControllerList 
{
    private static controllerDic:{ [key: string]: ControllerBase} = {}

    public static getControllerByKey(key:string):ControllerBase
    {
        if(ControllerList.controllerDic[key]==null)
            console.error("并没有与指定Key符合的控制器")

        return ControllerList.controllerDic[key]
    }

    public static addController(controller:ControllerBase):void
    {
        if(ControllerList.controllerDic[controller.getID()]!=null)
            console.error("尝试往全局Controller列表中添加Controller时,Controller并不存在.ID为:"+controller.getID())
        else
            controller[controller.getID()] = controller
    }
}

